﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HCMServices.DAO;
using HCMServices.DTO;
using System.Collections.Generic;

namespace HCMServices.Tests.TESTDAO
{
    /// <summary>
    /// Unit test for ServiceDAO class
    /// </summary>
    [TestClass]
    public class TestServiceDAO
    {
        /// <summary>
        /// Unit test for Search() method in ServiceDAO class
        /// </summary>
        [TestMethod]
        public void TestSearch()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            ServiceDAO serviceDao = new ServiceDAO(connectString);
            ServiceDTO serviceDTO = null;
            serviceDTO = serviceDao.Search(5);
            if (serviceDTO != null && serviceDTO.Id == 5 && serviceDTO.Name == "ATM")
            {
                Assert.IsTrue(true);
                return;
            }

            Assert.IsFalse(true);
        }

        /// <summary>
        /// Unit test for GetAllDichVuDTO() method in ServiceDAO class
        /// </summary>
        [TestMethod]
        public void TestGetAllDichVuDTO()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            ServiceDAO serviceDao = new ServiceDAO(connectString);
            List<ServiceDTO> listServiceDTO = null;
            listServiceDTO = serviceDao.GetAllDichVuDTO();
            if (listServiceDTO == null || listServiceDTO.Count == 0)
            {
                Assert.IsFalse(true);
            }

            foreach (ServiceDTO service in listServiceDTO)
            {
                if (service.Name == "Bệnh viện")
                {
                    if (service.Id != 1)
                    {
                        Assert.IsFalse(true);
                    }
                }
            }

            Assert.IsTrue(true);
        }

        /// <summary>
        /// Unit test for TestGetIdByName() method in ServiceDAO class
        /// </summary>
        [TestMethod]
        public void TestGetIdByName()
        {
            string connectString = "Data Source = isostore:/Database.sdf";

            ServiceDAO serviceDao = new ServiceDAO(connectString);
            int id = serviceDao.GetIdByName("Bệnh viện");
            if (id == 1)
            {
                Assert.IsTrue(true);
                return;
            }

            Assert.IsFalse(true);
        }
    }
}
